from libxml2 import parseFile

source = 'auto/desc.xml'
targetImpl = 'auto/functions.inc'
targetDecl = 'auto/methods.inc'
                    
from mako.template import Template
mytemplate = Template(filename='pari-functions.cpp.mako')

doc = parseFile(source)
root = doc.children

implFile = open(targetImpl, "w")
declFile = open(targetDecl, "w")

print >>implFile, mytemplate.render(root=root, implementation=1)
print >>declFile, mytemplate.render(root=root, implementation=0)

implFile.close();
declFile.close();
